package com.jvyou.thread.d09safe2;

import java.util.concurrent.locks.ReentrantLock;

/**
 * @author 橘柚
 * @version 1.0-SNAPSHOT
 * @Date 2024/7/31 11:19
 * @Description 同步方法
 */
public class SynchronizationMethod {

    public static void main(String[] args) {
        // 只创建一个对象
        TicketRunnable ticketRunnable = new TicketRunnable();
        // 同一个 Runnable 对象三个线程使用，三个线程共享同一个 Runnable 的this
        Thread thread1 = new Thread(ticketRunnable);
        Thread thread2 = new Thread(ticketRunnable);
        Thread thread3 = new Thread(ticketRunnable);

        thread1.setName("窗口1");
        thread2.setName("窗口2");
        thread3.setName("窗口3");

        thread1.start();
        thread2.start();
        thread3.start();

    }
}
